javascript loop array backwards

42

javascript loop array backwards -

let arr = [1, 2, 3];
arr.slice().reverse().forEach(x => console.log(x))

javascript loop array backwards -

var arr = [1, 2, 3, 4, 5];
 
for (var i = arr.length - 1; i >= 0; i--) {
    console.log(arr[i]);
}

javascript loop array backwards -

let arr = [1, 2, 3];

arr.slice().reverse().forEach(x => console.log(x))
 Run code snippet

JavaScript loop array backwards -

var arr = [1, 2, 3, 4, 5];
 
for (var i = arr.length - 1; i >= 0; i--) {
    console.log(arr[i]);
}

Comments

Submit
0 Comments